/*
tmock: Taller Technologies mock
    Copyright (C) 2014  Daniel Gutson, Andres Agustin Tiraboschi, Taller Technologies

    This file is part of tmock.

    tmock is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    tmock is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with tmock.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef PARSER_H
#define PARSER_H
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <fstream>
#include <list>
#include <sstream>
#include "gcc-plugin.h"
#include "tree.h"

using namespace std;

class FunctionToMock
{
    int id; /*only useful in option 2*/
    string name;
    string returnType;
    list<string> listArgs; /*list of the types of the arguments*/
    list<string> functionsToTest; /*list of the functions where this function will be mocked (only useful in option 2)*/
    string parseType(string& line);
    string argsToString(const bool type, const bool variable);
public:
    tree fntree; /*tree of the wrapper of the mock function that will after repace it in the functions to test*/
    bool declared; /*true iff the function is already declared*/

    string getName(void) const;
    const int getId(void) const;
    void insertFunctionToTest(const string name);
    const bool isFunctionToTest(const string name, const string end);
    void parse(string line);
    string declaration(const bool external, const bool original);
    string pointer(const bool external, const bool constant, const bool initialized, const string endl, const string endr);
    string definition(const string prev, const bool used);
};

typedef list<FunctionToMock> Functions;

Functions parseMockListFile(const string inputFile, size_t &line);

void writeIncMainFile(const string outputFile, Functions &functions);

FunctionToMock* getFunction(const string name, const string end, Functions &functions);

#endif /*PARSER_H*/
